// JavaScript Document
var details = {
	goods: function () {
		var get = bp.get_data()
		var data = {auctionCode:get.auctionCode};
		$.commonAjax({
			url: 'B035',
			type: 'POST',
			data: data,
			isShowError: true,
			success: function (res) {
				$('.titName').text(res.data.name);
				$('.active').text(res.data.visitCount+'次围观');
				$('.bond').children('span').text('￥'+res.data.marginAmount+'元');
				
				$('.f-list').children('div:eq(0)').text('起拍价：￥'+res.data.startingPrice);
				$('.f-list').children('div:eq(1)').text('计量：'+res.data.goods.quantity+res.data.unit);
			}, error: function (res) {
				$.layermsg(res.msg);
			}
		});
	},images_list:function(){
		var data = bp.get_data();
		//data.goodsCode = data.auctionCode;
		$.commonAjax({
			url: 'B036',
			type: 'POST',
			data: data,
			isShowError: true,
			success: function (res) {
				var htm = '';
				$.each(res.data,function(k,v){
					htm += '<div class="swiper-slide">';
					htm += '    <img src="'+CONFIG.imgUrl+v.largeUrl+'" alt="">';
					htm += '</div>';
				});
				$('.swiper-wrapper').html(htm);
				var swiper = new Swiper('.swiper-container', {
					pagination: '.swiper-pagination',
					paginationClickable: true,
					autoplay: 5000,
					autoplayDisableOnInteraction: false,
					loop: true
				});
			}, error: function (res) {
				$.layermsg(res.msg);
			}
		});
	},createOrder : function(){
		var data = bp.get_data();
		$.commonAjax({
			url: 'B056',
			type: 'POST',
			data: data,
			isShowError: true,
			success: function (res) {
				console.log(res.data);
				$.alert(res.msg)
				setTimeout(function(){bp.jump_data('pay.html?orderCode='+res.data.code);},1500)
			}, error: function (res) {
				$.layermsg(res.msg);
			}
		});
	}
}
$(function () {
	bp.user_info();
	details.goods();
	$(window).load(function () {
		details.images_list();
		
	});
	$('.bondBtn').click(function(){
			details.createOrder();
	});

	/*收藏*/
	$(".collection").click(function () {
		$(this).addClass("collection-active");
	})

	/*tab 切换*/
	$(".tab-list").click(function () {
		var idx = $(this).index();
		$(this).addClass("tab-list-active").siblings().removeClass("tab-list-active");
		$('div[class^="tab-content"]').hide();
		$(".tab-content" + idx).show();
	});

	/*底部 导航 切换*/
	$(".f-nav").click(function () {
		$(this).addClass("f-nav-active").siblings().removeClass("f-nav-active");
	});

	/*侧边的控制*/
	$(window).scroll(function () {
		var sTop = $(document).scrollTop();
		if (sTop > 100) {
			$(".aside-box").show();
		} else if (sTop < 100) {
			$(".aside-box").hide();
		}
	});

	/*回到顶部*/
	$(".goTopIcon").click(function () {
		$(document).scrollTop(0);
	});
})